
//初始值
export const initState = {
    //初始化数据
  //商品分类数据
  cate:[],
   //分类商品
  goods:[],
  //购物车添加
  cartadd:[]
  };
  
  //reducer 修改数据
  export const reducer = (state = initState, action) => {
    switch (action.type) {
      // 新人专享
      case 'changeCate':
        return {
          ...state,
          cate: action.cate,
        };
        case 'changeGoods':
        return {
          ...state,
          goods: action.goods,
        };
        case 'changeCartadd':
            return {
              ...state,
              cartadd: action.cartadd,
            };
      default:
        return state;
    }
  };
  //actionCreators组件派发的动作
  export const actions = {
    
    changeCate: (cate) => ({ type: 'changeCate', cate}),
    changeGoods: (goods) => ({ type: 'changeGoods', goods}),
    changeCartadd: (cartadd) => ({ type: 'changeCartadd', cartadd}),
  };
  
  
  